package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 获取积分消费列表请求参数
 * 
 * @author DLM
 *
 */
public class UserIntegralConsumeRecordListRequest extends Request {

	private static final long serialVersionUID = 4721382464881546717L;

	/**
	 * 用户id
	 */
	private Integer userId;
	
	/** 
	 * 当前页码 
	 */
	private int pageNum = 1;
	/**
	 * 每页条数 
	 */
	private int numPerPage = 10;
	
	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.pageNum = requestInfo.getIntParameter(ApiUrlParamEnum.pageNo.getParamName(),1);
		this.numPerPage = requestInfo.getIntParameter(ApiUrlParamEnum.pageSize.getParamName(), 10);
		
		if (userId < 1) {
			throw new RequestIllegalException("error userId:" + userId);
		}
		
		if (pageNum < 1) {
			throw new RequestIllegalException("error pageNum:" + pageNum);
		}
		
		if (numPerPage < 1) {
			throw new RequestIllegalException("error numPerPage:" + numPerPage);
		}
		
	}
	
	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(int numPerPage) {
		this.numPerPage = numPerPage;
	}


}
